import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/special_list/process_nodes_entity.dart';

class EmergencyPlanDetailsController extends GetxController with GetSingleTickerProviderStateMixin {
  /// 预案id
  String id = Get.arguments['id'] as String;

  /// 1-待发起 2-待审批 3-审批中 4-通过 5-已驳回 6-待发布 7- 已发布
  int state = Get.arguments['status'] as int;

  late TabController tabController; //TabController 变量

  /// 审批流程数据
  List<ProcessNodesEntity>? nodeList;

  @override
  void onInit() {
    super.onInit();
    //初始化tabController
    tabController = TabController(vsync: this, length: 5);
    // 获取基本信息
    getProcessListData();
  }

  /// 获取流程列表数据
  void getProcessListData() async {
    // 获取流程列表接口
    final res = await HttpUtil().generateGetRequest<List<ProcessNodesEntity>>(
      Interface.getProcessArrangeRecord,
      queryParameters: {'emergencyPlansId': id, 'businessType': 'm2'},
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        nodeList = result.data!;
      }
      update();
    });
  }
}
